package io.github.syske.springbootjdbcmybatisdemo.call;

import java.sql.*;

public class OracleStoredProcedureExample {

    public static void main(String[] args) {
        String url = "jdbc:oracle:thin:@127.0.0.1:1521/MWMS";
        String user = "std_mwms_whqr";
        String password = "hsbk_feng_whqr";
        String inputParam = "000000000376";

        try (Connection conn = DriverManager.getConnection(url, user, password)) {
            String sql = "{ call sp_Xml_Sel_L(?, ?) }"; // 调用存储过程的SQL语句
            try (CallableStatement stmt = conn.prepareCall(sql)) {
                stmt.setString(1, inputParam); // 设置输入参数的值
                stmt.registerOutParameter(2, Types.VARCHAR); // 注册输出参数的类型

                stmt.execute(); // 执行存储过程

                String outputParam = stmt.getString(2); // 获取输出参数的值
                System.out.println("Output parameter: " + outputParam);
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}

